package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.StorageCapacity;
import com.ruoyi.system.service.StorageCapacityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 存储容量统计Controller
 * 处理存储容量的增删改查请求
 *
 * @author admin
 * @date 2025-08-24
 */
@RestController
@RequestMapping("/system/storageCapacity")
public class StorageCapacityController extends BaseController {
    @Autowired
    private StorageCapacityService storageCapacityService;

    /**
     * 1. 查询存储容量统计列表（分页）
     */
    @GetMapping("/list")
    public TableDataInfo list(StorageCapacity storageCapacity) {
        startPage();
        List<StorageCapacity> list = storageCapacityService.selectStorageCapacityList(storageCapacity);
        return getDataTable(list);
    }

    /**
     * 2. 查询存储容量统计详情
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(storageCapacityService.selectStorageCapacityById(id));
    }

    /**
     * 3. 新增存储容量统计
     */
    @PostMapping
    public AjaxResult add(@RequestBody StorageCapacity storageCapacity) {
        return toAjax(storageCapacityService.insertStorageCapacity(storageCapacity));
    }

    /**
     * 4. 修改存储容量统计
     */
    @PutMapping
    public AjaxResult edit(@RequestBody StorageCapacity storageCapacity) {
        return toAjax(storageCapacityService.updateStorageCapacity(storageCapacity));
    }

    /**
     * 5. 删除存储容量统计（单条/批量）
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(storageCapacityService.deleteStorageCapacityByIds(ids));
    }
}